﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace UTIL
{
    public class FindWindow1
    {
       #region Dll Import
 
        [DllImport("User32.dll",EntryPoint="FindWindow")] 
        private static extern IntPtr FindWindow(string lpClassName, 
    string lpWindowName); 
     
        [DllImport("user32.dll",EntryPoint="FindWindowEx")] 
        private static extern IntPtr FindWindowEx(IntPtr hwndParent, 
    IntPtr hwndChildAfter, string lpszClass, string lpszWindow); 
     
        [DllImport("User32.dll",EntryPoint="SendMessage")] 
        private static extern int SendMessage(IntPtr hWnd, 
    int Msg, IntPtr wParam, string lParam);
        const int WM_GETTEXT = 0x000D;
        const int WM_SETTEXT = 0x000C;
        const int WM_CLICK = 0x00F5; 
    #endregion 

        public void  SearchWindow(string lpszParentClass, string lpszParentWindow)
        {
            IntPtr ParenthWnd = new IntPtr(0);
            IntPtr EdithWnd = new IntPtr(0);
            //查到窗体，得到整个窗体 
            ParenthWnd = FindWindow(lpszParentClass, lpszParentWindow);

            //判断这个窗体是否有效 
            if (!ParenthWnd.Equals(IntPtr.Zero))
            {
                SendMessage(ParenthWnd,16, IntPtr.Zero, "0");      
            }           
        } 

    }
}

